<!DOCTYPE html>
<html>
<head>
    <meta content="text/html" charset="UTF-8">
    <title>jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="css/themes/default/easyui.css">
    <link rel="stylesheet" href="css/themes/icon.css"/>
    <link rel="stylesheet" type="text/css" href="css/mycss.css"/>
    <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
</head>
<body>
<table id="test_msg"></table>
<script type="text/javascript">
    var $test_msg=$('#test_msg');
    $test_msg.datagrid({
        url:'textmsg/list.json',
        saveUrl:'textmsg/api?method=add',
        editUrl: 'textmsg/api?method=update',
        delUrl: 'textmsg/api?method=del',
        columns:[[
            {field:'ck',checkbox:true},
            {field:'id',title:'MsgId'},
            {field:'text',title:'内容',width:600,editor:{type:'textarea',options:{required:true}}},
            {field:'time',title:'创建时间',formatter:function(value){
                return new Date(value).toLocaleString();
            }},
            {field:'edittime',title:'修改时间',formatter:function(value){
                return new Date(value).toLocaleString();
            }}
        ]],
        onBeforeEdit:function(rowIndex){
            var edititem=$test_msg.datagrid('options').edititem;
            edititem.push(rowIndex);
        },
        onDblClickRow:function(rowIndex){
            $test_msg.datagrid('beginEdit', rowIndex);
        },
        toolbar:[
            {
                iconCls:'icon-add',
                text:'添加',
                handler:function(){
                    $test_msg.datagrid('addRow',{
                        //"id": textitemindex--,
                        "text": "新内容"
                    });
                }
            },
            {
                iconCls:'icon-save',
                text:'接受改变',
                handler:function(){
                    $test_msg.datagrid('RecChange');
                }
            },
            {
                iconCls:'icon-save',
                text:'保存',
                handler:function(){
                	$test_msg.datagrid('SaveData');
                }
            },
            {
                iconCls:'icon-cancel',
                text:'取消更改',
                handler:function(){
                    $test_msg.datagrid('CancelEdit');
                }
            },
            {
                iconCls:'icon-remove',
                text:'删除选中行',
                handler:function(){
                   	$test_msg.datagrid('DelRows');
                }
            }
        ]
    });

    function del (){
        var rows =  $test_msg.edatagrid("getChecked");
        $test_msg.edatagrid('destroyRow',rows);
    }
</script>
</body>
<script type="text/javascript">
    alert("init");
</script>
<script type="text/javascript" src="js/easyui-lang-zh_CN.js"></script>
</html>